package astudy.javadoc;

import java.io.File;
import java.util.Arrays;

import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaSource;

/**
 * Test QDox to create javadoc
 * @author wong.tong@gmail.com
 *
 */
public class QDox {
	
	public static void main(String[] args) throws Exception {
		
		JavaDocBuilder builder = new JavaDocBuilder();
		builder.setEncoding("UTF-8");
//		URL url = QDox.class.getResource("FooBarClass.java");
//		File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
		File file = new File("D:/develop/Java/experiments/astudy/test/astudy/javadoc/FooBarClass.java");
		builder.addSource(file);

		JavaSource src = builder.getSources()[0];

		System.out.println("package: " + src.getPackage());
		System.out.println("imports: " + Arrays.asList(src.getImports()));
		
		String[] tags = new String[] {
				"ssedw.doc.code", 
				"ssedw.doc.description", 
				"ssedw.doc.author", 
				"ssedw.doc.history"
		};
		for (JavaClass jcls: src.getClasses()) {
			for (String tag: tags) {
				String value = jcls.getTagByName(tag).getValue();
				System.out.println(tag + "\t: " + value);
			}
		}
	}
}
